package metro.cards;

import metro.cards.types.CardType;
import metro.response.Response;
import metro.system.MetroSystem;
import metro.tourniquet.Tourniquet;

import java.util.Calendar;

public class EntranceCard extends Card {
    private int availableEntrance;

    protected EntranceCard(Calendar creationDate,int available) {
        this(creationDate);
        this.availableEntrance = available;

    }

    private EntranceCard(Calendar creationDate){
        super(creationDate);
        type = CardType.ENTRANCE_CARD;
    }

    public static EntranceCard createTenEntranceCard(Calendar creationDate){
        return new EntranceCard(creationDate,10);
    }

    public static EntranceCard createTwentyEntranceCard(Calendar creationDate){
        return new EntranceCard(creationDate,20);
    }

    public int getAvailableEntrance() {
        return availableEntrance;
    }

    @Override
    public Response use(MetroSystem system,Tourniquet tourniquet) {
        if (availableEntrance >0){
            availableEntrance--;
            return Response.createPositiveEntranceResponse(this,tourniquet);
        } else
            return Response.createNegativeEntranceResponse(this,tourniquet);
    }
}
